<template>
	<view class="list">
		<view class="customer" style="padding: 20rpx;">
			{{entity.cCusName}}
		</view>
		<!-- <uni-list>
			<uni-list-item v-for="item in data" :key="item.Id" :title="'单号: '+item.Id"
				:note="item.CreateTime?item.CreateTime.substring(0,19)+' '+payType[item.PayType]:''"
				:rightText=" '￥'+momenyFormat(item.Money)" />
		</uni-list> -->
		
		<view class="listBox">
			<view class="listItem"  v-for="item in data" :key="item.Id">
				<view class="left" >
					<text style="margin-bottom: 10rpx;">单号:{{item.Id}} </text>
					<text>{{item.CreateTime?item.CreateTime.substring(0,19):' '}} <text style="margin-left: 40rpx;"> {{payType[item.PayType]}}</text> </text>
				</view>
				<view class="right">
					<text>￥<text>{{momenyFormat(item.Money)}}</text> </text>
				</view>
				
			</view>
			
		</view>
		
		<leruge-empty v-if="data.length==0 " text="暂无收款记录" type="minus"></leruge-empty>
		
		<!-- 上拉显示更多 -->
		<view v-if="data.length !=0" class="" style="padding-bottom: 60rpx;">
			<uniLoadMore :status="status" :contentText="contentText" :rows="data"></uniLoadMore>
		</view>
		
	</view>
</template>

<script>
	// 引入加载更多
	import uniLoadMore from '@/components/uni-load-more.vue'
	// 引入暂无提示
	import lerugeEmpty from '@/components/empty/empty.vue'
	import {
		momenyFormat
	} from '@/util/util.js'
	export default {
		components:{
			lerugeEmpty,
			uniLoadMore
		},
		data() {
			return {
				// 加载状态
				status: "loading",
				contentText: {
					contentdown: '',
					contentrefresh: '加载中',
					contentnomore: '没有更多了'
				},
				entity: {},
				data: [],
				payType: ['转账', '微信', '支付宝', '现金'],
				pagination: {
					PageIndex: 1,
					PageRows: 10,
					SortField: "CreateTime",
					SortType: "desc",
				},
				total: 0,
			}
		},
		
		// 下拉刷新
		onPullDownRefresh() {
			// 重置相关参数
			this.pagination.PageIndex=1
			this.pagination.PageRows=10
			this.data=[]
			this.getDataList()
			// this.getOpenOrderListData()
			uni.stopPullDownRefresh(); //停止刷新
		},
		
		
		onLoad(query) {
			console.log(query);
			uni.setNavigationBarTitle({
				title: query.key
			})
			this.entity = JSON.parse(query.data)
			this.getDataList()
		},
		onReachBottom() {
			this.$http('post', '/BO/BIllcollection/GetDataList', {
				...this.pagination,
				Search: {
					CustomerId: this.entity.CustomerId,
					Type: 0
				}
			}).then(res => {
				console.log(res);
				if (!res.Success) return this.$api.msg(res.Msg)
				this.data = this.data.concat(res.Data)
				this.total = res.total
			})
		},
		methods: {
			getDataList() {
				this.status="loading"
				this.$http('post', '/BO/BIllcollection/GetDataList', {
					...this.pagination,
					Search: {
						CustomerId: this.entity.CustomerId,
						Type: 0
					}
				}).then(res => {
					console.log(res);
					if(res.Success){
						this.total = res.total
						let lists = res.Data
						if(lists.length ==0 || lists ==[]){
							this.status = "noMore"
							return
						}
						
						if(this.pagination.PageIndex==1){
							this.data = res.Data
							this.pagination.PageIndex++
						}else{
							this.data = this.data.concat(lists)
						}
						if(this.pagination.PageIndex*this.pagination.PageRows>=this.total){
							this.status="noMore"
							return
						}
						this.status="noMore"
					}else{
						this.$api.msg(res.Msg)
						return 
					}
				})
			},
			// 千分位
			momenyFormat(num) {
				return momenyFormat(num)
			}
		}
	}
</script>

<style scoped lang="scss">
	.list {
		.listBox{
			.listItem{
				display: flex;
				background-color: #fff;
				border-radius: 15rpx;
				 box-shadow: 0 6px 19px rgba(0, 0, 0, 0.4);
				margin: 20rpx;
				padding: 20rpx;
				align-items: center;
				justify-content: space-between;
				.left{
					display: flex;
					flex-direction: column;
				}
				
			}
		}
	}
</style>